package com.vq3.digitalizationsoftwareintegrates.Servlet.BusinessCenter.Spot_Check;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.vq3.digitalizationsoftwareintegrates.Entity.Enum.Group_Type;
import com.vq3.digitalizationsoftwareintegrates.Entity.Enum.MessageType;
import com.vq3.digitalizationsoftwareintegrates.Entity.Enum.S_CType;
import com.vq3.digitalizationsoftwareintegrates.Entity.Enum.StatusType;
import com.vq3.digitalizationsoftwareintegrates.Entity.Info.ResultInfo;
import com.vq3.digitalizationsoftwareintegrates.Entity.Spot_Check.*;
import com.vq3.digitalizationsoftwareintegrates.Entity.Spot_Check.MongoDBEntity.MongoDB_S_C_Point_ContentEntity;
import com.vq3.digitalizationsoftwareintegrates.Entity.Spot_Check.MongoDBEntity.MongoDB_S_C_SaveSCDailyContextEntity;
import com.vq3.digitalizationsoftwareintegrates.Entity.Spot_Check.MongoDBEntity.MongoDB_S_C_WebSocketMessageEntity;
import com.vq3.digitalizationsoftwareintegrates.Entity.Spot_Check.MongoDBEntity.MongoDB_S_C_WebSocketSendMessageEntity;
import com.vq3.digitalizationsoftwareintegrates.Entity.User.Permission_TBEntity;
import com.vq3.digitalizationsoftwareintegrates.Entity.User.URole_TBEntity;
import com.vq3.digitalizationsoftwareintegrates.Entity.User.UserEntity;
import com.vq3.digitalizationsoftwareintegrates.MongoDB.Spot_Check.MongoDB_S_C_SaveDailyContextDao;
import com.vq3.digitalizationsoftwareintegrates.Service.Spot_Check.Spot_Check_FusionService;
import com.vq3.digitalizationsoftwareintegrates.Servlet.WebSocket.WebSocketServer;
import com.vq3.digitalizationsoftwareintegrates.Utils.DateUtils.GetServerDate;
import com.vq3.digitalizationsoftwareintegrates.Utils.DateUtils.StringToDate;
import com.vq3.digitalizationsoftwareintegrates.Utils.ImageUtil.CalculationIsNull;
import com.vq3.digitalizationsoftwareintegrates.Utils.ImageUtil.CalculationIsType;
import com.vq3.digitalizationsoftwareintegrates.Utils.ImageUtil.ImageUtil;
import com.vq3.digitalizationsoftwareintegrates.Utils.PackagedDataUtil.Impl.PackagedDataImpl;
import com.vq3.digitalizationsoftwareintegrates.Utils.PackagedDataUtil.PackagedData;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Import;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;


import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.websocket.EncodeException;
import java.io.*;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.ExecutionException;


/**点检综合业务控制器
 *
 * */
@Slf4j
@RestController
@RequestMapping("spot_check")
@Import({S_C_Point_ContentEntity.class, ImageUtil.class, CalculationIsNull.class})
public class Spot_Check_FusionServlet {
    @Resource
    MongoDB_S_C_SaveDailyContextDao mongoDB_s_c_saveDailyContextDao;


    final Spot_Check_FusionService spot_check_fusionService;
    final WebSocketServer webSocketServer;

    public Spot_Check_FusionServlet(Spot_Check_FusionService spot_check_fusionService, WebSocketServer webSocketServer) {
        this.spot_check_fusionService = spot_check_fusionService;
        this.webSocketServer = webSocketServer;
    }


    @PostMapping("/addPointName")
    public void addPointName(@RequestParam("post_check_Point_Name") String post_check_Point_Name,HttpServletResponse httpServletResponse, HttpServletRequest httpServletRequest) throws IOException {
        httpServletRequest.getSession().setAttribute("POINT_NAME",post_check_Point_Name);
        PackagedData packagedData = new PackagedDataImpl();
        ResultInfo resultInfo = spot_check_fusionService.addPointName(post_check_Point_Name);


        packagedData.writeValue(resultInfo,httpServletResponse);


    }
    /**文字数据清洗
     * */

    @PostMapping("/checkIsNull")
    public void checkIsNull(@RequestBody Map<String,List<String>> map,HttpServletResponse httpServletResponse, HttpServletRequest httpServletRequest) throws IOException, ExecutionException, InterruptedException {

        PackagedData packagedData = new PackagedDataImpl();
        ResultInfo resultInfo = spot_check_fusionService.checkIsNull(map);
        packagedData.writeValue(resultInfo,httpServletResponse);


    }
    /**文件数据清洗
     * */
    @PostMapping("/loadImage")
    public void loadImage(@RequestParam("file") List<MultipartFile> files, @RequestParam("num") List<String> thisNull,@RequestParam("a_row_col_inArrName") List<String> nameArr,@RequestParam("sc_fun") List<String> funArr,@RequestParam("benchmarkArr") List<String> benchmarkArr, HttpServletResponse httpServletResponse, HttpServletRequest httpServletRequest) throws IOException, ExecutionException, InterruptedException {

        PackagedData packagedData = new PackagedDataImpl();
        ResultInfo resultInfo = spot_check_fusionService.loadImage(files, thisNull, nameArr,funArr,benchmarkArr,httpServletRequest);
        packagedData.writeValue(resultInfo,httpServletResponse);

    }
    @PostMapping("/downLoadImage")
    public void downLoadImage(HttpServletRequest httpServletRequest,HttpServletResponse httpServletResponse) throws IOException {

        PackagedData packagedData = new PackagedDataImpl();
        String point_name = (String)httpServletRequest.getSession().getAttribute("POINT_NAME");
        UserEntity userEntity = (UserEntity)httpServletRequest.getSession().getAttribute("USER");
        List<S_C_Point_ContentEntity> s_c_point_contentEntities = spot_check_fusionService.downLoadImage(point_name, userEntity, S_CType.TEMP);

        packagedData.writeValue(s_c_point_contentEntities,httpServletResponse);

    }
    //TODO  12.2 这里需要一个”Spot_Check_Add_Background.html“页面点击”修改“按钮后需要及时删除MongoDB里的相关内容，与临时图片库的内容，否则会出现找不到文件的错误，下一次开工一定要处理这个！！！！！
    @PostMapping("/reviseItem")
    public void reviseItem(HttpServletRequest httpServletRequest,HttpServletResponse httpServletResponse) {
        String point_name = (String)httpServletRequest.getSession().getAttribute("POINT_NAME");
        UserEntity userEntity = (UserEntity)httpServletRequest.getSession().getAttribute("USER");
        spot_check_fusionService.reviseItem(point_name, userEntity, S_CType.TEMP, StatusType.NotSubmitted);


    }
    @PostMapping("/check_ok_submit")
    public void check_ok_submit(@RequestParam String pointName,@RequestParam String groupOption,HttpServletRequest httpServletRequest,HttpServletResponse httpServletResponse) throws IOException, EncodeException {
        ResultInfo resultInfo = new ResultInfo();
        PackagedData packagedData = new PackagedDataImpl();
        Group_Type group_type = CalculationIsType.calculationIsGroupType(groupOption);
        boolean b = spot_check_fusionService.check_ok_submit(pointName, StatusType.NotSubmitted,group_type);
        resultInfo.setFlag(b);
        if (resultInfo.isFlag()){
            List<MongoDB_S_C_Point_ContentEntity> mongoDB_s_c_point_contentEntities = spot_check_fusionService.itemNameFindMongoDB_S_C_Point_ContentEntity(pointName);
            MongoDB_S_C_WebSocketMessageEntity mongoDB_s_c_webSocketMessageEntity_sun = new MongoDB_S_C_WebSocketMessageEntity();
            MongoDB_S_C_WebSocketSendMessageEntity mongoDB_s_c_webSocketMessageEntity = new MongoDB_S_C_WebSocketSendMessageEntity();
            UserEntity userEntity = (UserEntity) httpServletRequest.getSession().getAttribute("USER");
            /*List<URole_TBEntity> uRole_tbEntity_s_c_audit = spot_check_fusionService.findURole_TBEntity_S_C_Audit();*/
            Permission_TBEntity permission_tbEntity = new Permission_TBEntity(4,"s3","点检系统的审核");
            List<Permission_TBEntity> permission_tbEntities = new ArrayList<>();
            permission_tbEntities.add(permission_tbEntity);

            mongoDB_s_c_webSocketMessageEntity_sun.setPermission_tbEntities(permission_tbEntities);
            mongoDB_s_c_webSocketMessageEntity_sun.setLastUserEntity(userEntity);

            GetServerDate.getMessageTime(mongoDB_s_c_webSocketMessageEntity_sun);
            mongoDB_s_c_webSocketMessageEntity.setItemName(pointName);
            mongoDB_s_c_webSocketMessageEntity.setImportantNewsMessageEntity(false);
            GetServerDate.getMessageTime(mongoDB_s_c_webSocketMessageEntity);
            mongoDB_s_c_webSocketMessageEntity.setPermission_tbEntities(permission_tbEntities);

            mongoDB_s_c_webSocketMessageEntity.setMessage("您有新的"+MessageType.S_CAddAuditMessage+"待处理");
            mongoDB_s_c_webSocketMessageEntity_sun.setMessage(mongoDB_s_c_webSocketMessageEntity.getMessage());
            mongoDB_s_c_webSocketMessageEntity_sun.setMongoDB_s_c_point_contentEntityS(mongoDB_s_c_point_contentEntities);
            mongoDB_s_c_webSocketMessageEntity_sun.setItemName(pointName);
            mongoDB_s_c_webSocketMessageEntity.setMongoDB_s_c_webSocketMessageEntity(mongoDB_s_c_webSocketMessageEntity_sun);
            webSocketServer.sendToUser(mongoDB_s_c_webSocketMessageEntity, MessageType.S_CAddAuditMessage);
            resultInfo.setErrorMsg("提交成功！");
        }else {
            resultInfo.setErrorMsg("提交失败！请联系系统管理员！");
        }
        packagedData.writeValue(resultInfo,httpServletResponse);
    }

    @RequestMapping("getS_CContext")
    public void getS_CContext(@RequestParam String pointName, @RequestParam String date, HttpServletResponse httpServletResponse, HttpServletRequest httpServletRequest) throws ParseException, IOException {
        ResultInfo resultInfo = new ResultInfo();
        PackagedData packagedData = new PackagedDataImpl();
        List<MongoDB_S_C_SaveSCDailyContextEntity> sCSaveSCDailyContextEntities = spot_check_fusionService.findMongoDBSCDaily(pointName, StringToDate.stringToDate(date));
        if (sCSaveSCDailyContextEntities.isEmpty()){
            List<S_C_DatesEntity> s_cContext = spot_check_fusionService.getS_CContext(pointName, StringToDate.stringToDate(date));
            if (s_cContext.isEmpty()) {
                resultInfo.setFlag(false);
                resultInfo.setErrorMsg("查询错误");
            }else {
                resultInfo.setFlag(true);
                resultInfo.setData(s_cContext);
            }
        }else {
            resultInfo.setFlag(true);
            resultInfo.setData(sCSaveSCDailyContextEntities.get(0).getSCDatesEntityS());
        }

        packagedData.writeValue(resultInfo,httpServletResponse);
    }
    @RequestMapping("getS_CPointName")
    public void getS_CPointName(HttpServletResponse httpServletResponse,HttpServletRequest httpServletRequest) throws IOException {

        ResultInfo resultInfo = new ResultInfo();
        PackagedData packagedData = new PackagedDataImpl();

        UserEntity userEntity = (UserEntity)httpServletRequest.getSession().getAttribute("USER");



        List<S_C_PointEntity> allPointTODataCenter = spot_check_fusionService.groupIdFindPoint(userEntity.getGroupId());
        List<S_C_PointEntity> allPointTODataCenterAdd = new ArrayList<>();
        if (!allPointTODataCenter.isEmpty()) {
            for (S_C_PointEntity s_c_pointEntity : allPointTODataCenter) {
                if (allPointTODataCenterAdd.isEmpty()) {
                    allPointTODataCenterAdd.add(s_c_pointEntity);
                } else {
                    if (!(allPointTODataCenterAdd.get(allPointTODataCenterAdd.size() - 1).getPointName().equalsIgnoreCase(s_c_pointEntity.getPointName()))) {
                        allPointTODataCenterAdd.add(s_c_pointEntity);
                    }

                }
            }

            resultInfo.setData(allPointTODataCenterAdd);
            resultInfo.setFlag(true);
        }else {
            resultInfo.setFlag(false);
            resultInfo.setErrorMsg("您暂无访问权限！");
        }



        packagedData.writeValue(resultInfo,httpServletResponse);


    }
    @RequestMapping("getS_CContextItems")
    public void getS_CContextItems(@RequestParam String pointName, HttpServletResponse httpServletResponse, HttpServletRequest httpServletRequest) throws IOException {
        List<S_C_Point_ContentEntity> s_cContextItems = spot_check_fusionService.getS_CContextItems(pointName);
        PackagedData packagedData = new PackagedDataImpl();
        packagedData.writeValue(s_cContextItems,httpServletResponse);
    }

    @RequestMapping("saveSCDailyContext")
    public void saveSCDailyContext(@RequestBody S_C_DatesEntity[] sCDatesEntities, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws EncodeException, IOException {
        List<S_C_DatesEntity> s_c_datesEntities = new ArrayList<>();
        List<S_C_DatesEntity> exSCDatesEntities = new ArrayList<>();
        MongoDB_S_C_WebSocketSendMessageEntity messageEntity = new MongoDB_S_C_WebSocketSendMessageEntity();
        MongoDB_S_C_WebSocketMessageEntity mongoDBSCWebSocketMessageEntity = new MongoDB_S_C_WebSocketMessageEntity();
        ResultInfo resultInfo = new ResultInfo();
        PackagedData packagedData = new PackagedDataImpl();

        //验证点检是否完成
        boolean isNullFlag = false;
        int nullIndex = 0;
        for (S_C_DatesEntity sCDatesEntity : sCDatesEntities) {
            nullIndex++;
            if (!(sCDatesEntity.getPointContentMiddayStatusId() != null || sCDatesEntity.getPointContentMorningStatusId() != null)) {
                isNullFlag = true;
                break;
            }
        }

        if (isNullFlag) {
            resultInfo.setFlag(false);
            resultInfo.setErrorMsg("第"+nullIndex+"项点检项目未完成,请检查!");
        }else {
            List<Permission_TBEntity> permission_tbEntities = new ArrayList<Permission_TBEntity>();
            Permission_TBEntity permission_tbEntity = new Permission_TBEntity(13, "s5", "点检系统的异常对应");

            permission_tbEntities.add(permission_tbEntity);

            mongoDBSCWebSocketMessageEntity.setPermission_tbEntities(permission_tbEntities);



            boolean flag = false;

            for (S_C_DatesEntity sCDatesEntity : sCDatesEntities) {
                s_c_datesEntities.add(sCDatesEntity);
                try {
                    if (sCDatesEntity.getPointContentMorningStatusId() != null){
                        flag = sCDatesEntity.getPointContentMorningStatusId() == 1;
                    }else if (sCDatesEntity.getPointContentMiddayStatusId() != null) {
                        flag = sCDatesEntity.getPointContentMiddayStatusId() == 1;
                    }else {
                        flag =false;
                    }
                    if (!flag){
                        exSCDatesEntities.add(sCDatesEntity);
                    }

                }catch (NullPointerException e) {
                    e.getMessage();
                }

            }
            mongoDBSCWebSocketMessageEntity.setS_c_datesEntities(exSCDatesEntities);
            messageEntity.setMongoDB_s_c_webSocketMessageEntity(mongoDBSCWebSocketMessageEntity);


            //审核通过后访问这个接口
            /*spot_check_fusionService.saveSCDailyContext(s_c_datesEntities);*/
            String point = sCDatesEntities[0].getPoint();
            Date date = sCDatesEntities[0].getDate();
            List<MongoDB_S_C_SaveSCDailyContextEntity> s_cContext = spot_check_fusionService.findMongoDBSCDaily(point, date);
            MongoDB_S_C_SaveSCDailyContextEntity mongoDB_s_c_saveSCDailyContextEntity_New = new MongoDB_S_C_SaveSCDailyContextEntity();
            List<Permission_TBEntity> permission_tbEntityList = new ArrayList<>();
            boolean b;
            if (s_cContext.isEmpty()){

                /**MongoDB_S_C_SaveSCDailyContextEntity mongoDB_s_c_saveSCDailyContextEntity = new MongoDB_S_C_SaveSCDailyContextEntity();
                 mongoDB_s_c_saveSCDailyContextEntity.setSCDatesEntityS(s_c_datesEntities);
                 Permission_TBEntity permission_tbEntity = new Permission_TBEntity(10, "s4", "点检业务审核");
                 List<Permission_TBEntity> permission_tbEntities = new ArrayList<>();
                 permission_tbEntities.add(permission_tbEntity);
                 mongoDB_s_c_saveSCDailyContextEntity.setPermission_tbEntities(permission_tbEntities);

                 * */
                permission_tbEntityList.add(new Permission_TBEntity(10,"s4","点检业务审核"));
                if (!exSCDatesEntities.isEmpty()){

                    permission_tbEntityList.add(new Permission_TBEntity(13,"s5","点检系统的异常对应"));

                    webSocketServer.sendToUser(messageEntity,MessageType.SCExceptionCorrespondence);
                }
                mongoDB_s_c_saveSCDailyContextEntity_New.setSCDatesEntityS(s_c_datesEntities);
                mongoDB_s_c_saveSCDailyContextEntity_New.setPermission_tbEntities(permission_tbEntityList);
                b = mongoDB_s_c_saveDailyContextDao.saveSCDailyContext(mongoDB_s_c_saveSCDailyContextEntity_New);
            }else {
                MongoDB_S_C_SaveSCDailyContextEntity mongoDB_s_c_saveSCDailyContextEntity = s_cContext.get(0);
                List<Permission_TBEntity> permission_tbEntities1 = mongoDB_s_c_saveSCDailyContextEntity.getPermission_tbEntities();
                boolean s5_Flag = true;
                boolean s3_Flag = true;

                for (Permission_TBEntity permissionTbEntity : permission_tbEntities1) {
                    if (!exSCDatesEntities.isEmpty()){
                        if (permissionTbEntity.getPermission().equalsIgnoreCase("s5")) {
                            s5_Flag = false;
                        }
                    }
                    if (permissionTbEntity.getPermission().equalsIgnoreCase("s4")){
                        s3_Flag = false;
                    }
                }

                if (s5_Flag){
                    permission_tbEntities1.add(new Permission_TBEntity(13,"s5","点检系统的异常对应"));
                }

                if (s3_Flag) {
                    permission_tbEntities1.add(new Permission_TBEntity(10,"s4","点检业务审核"));
                }
                /*5+5*/
                // TODO: 2023/2/23 这样写显得很没有水平,项目完工后想想怎么优化
                for (int i = 0; i < sCDatesEntities.length; i++) {
                    //早班  开始
                    if (sCDatesEntities[i].getPointContentMorningUid() != null) {
                        mongoDB_s_c_saveSCDailyContextEntity.getSCDatesEntityS().get(i).setPointContentMorningUid(sCDatesEntities[i].getPointContentMorningUid());
                    }
                    if (sCDatesEntities[i].getPointContentMorningStatusId() != null){
                        mongoDB_s_c_saveSCDailyContextEntity.getSCDatesEntityS().get(i).setPointContentMorningStatusId(sCDatesEntities[i].getPointContentMorningStatusId());
                    }
                    if (sCDatesEntities[i].getMorningAuditUid() != null) {
                        mongoDB_s_c_saveSCDailyContextEntity.getSCDatesEntityS().get(i).setMorningAuditUid(sCDatesEntities[i].getMorningAuditUid());
                    }
                    if (sCDatesEntities[i].getMorningExceptionCorrespondence() != null) {
                        mongoDB_s_c_saveSCDailyContextEntity.getSCDatesEntityS().get(i).setMorningExceptionCorrespondence(sCDatesEntities[i].getMorningExceptionCorrespondence());
                    }
                    if (sCDatesEntities[i].getMorningEXDescription() != null) {
                        mongoDB_s_c_saveSCDailyContextEntity.getSCDatesEntityS().get(i).setMorningEXDescription(sCDatesEntities[i].getMorningEXDescription());
                    }
                    //早班  结束
                    //中班  开始
                    if (sCDatesEntities[i].getPointContentMiddayUid() != null) {
                        mongoDB_s_c_saveSCDailyContextEntity.getSCDatesEntityS().get(i).setPointContentMiddayUid(sCDatesEntities[i].getPointContentMiddayUid());
                    }
                    if (sCDatesEntities[i].getPointContentMiddayStatusId() != null){
                        mongoDB_s_c_saveSCDailyContextEntity.getSCDatesEntityS().get(i).setPointContentMiddayStatusId(sCDatesEntities[i].getPointContentMiddayStatusId());
                    }
                    if (sCDatesEntities[i].getMiddayAuditUid() != null) {
                        mongoDB_s_c_saveSCDailyContextEntity.getSCDatesEntityS().get(i).setMiddayAuditUid(sCDatesEntities[i].getMiddayAuditUid());
                    }
                    if (sCDatesEntities[i].getMiddayExceptionCorrespondence() != null) {
                        mongoDB_s_c_saveSCDailyContextEntity.getSCDatesEntityS().get(i).setMiddayExceptionCorrespondence(sCDatesEntities[i].getMiddayExceptionCorrespondence());
                    }
                    if (sCDatesEntities[i].getMiddayEXDescription() != null) {
                        mongoDB_s_c_saveSCDailyContextEntity.getSCDatesEntityS().get(i).setMiddayEXDescription(sCDatesEntities[i].getMiddayEXDescription());
                    }
                    //中班  结束

                }
                b = mongoDB_s_c_saveDailyContextDao.updateSCDailyContext(mongoDB_s_c_saveSCDailyContextEntity);
            }
            resultInfo.setFlag(b);
            resultInfo.setErrorMsg("数据更新失败,请联系系统管理员!");
        }
        packagedData.writeValue(resultInfo,httpServletResponse);
    }

    @RequestMapping("conditionalQueries")
    public void conditionalQueries(@RequestParam int page,@RequestParam(value = "groupOption",required = false) String groupOption,
                                   @RequestParam(value = "point_name",required = false) String point_name,HttpServletResponse httpServletResponse) throws IOException {
        ResultInfo resultInfo = new ResultInfo();
        PackagedData packagedData = new PackagedDataImpl();
        System.out.println("groupOption:"+groupOption);
        System.out.println("point_name:"+point_name);
        try {


        if ((groupOption != null && point_name != null) && (!"".equalsIgnoreCase(groupOption) && !"".equalsIgnoreCase(point_name))){
            IPage<S_C_PointEntity> s_c_pointEntities = spot_check_fusionService.conditionalQueries(CalculationIsType.calculationIsGroupTypeToMySql(CalculationIsType.calculationIsGroupType(groupOption)), point_name,page);
            System.out.println(111);
            if (s_c_pointEntities.getCurrent() < 1){
                resultInfo.setFlag(false);
                resultInfo.setErrorMsg("查询为空！");
            }else {
                resultInfo.setFlag(true);
                resultInfo.setData(s_c_pointEntities);
            }
        }else if (groupOption == null && point_name != null){
            IPage<S_C_PointEntity> s_c_pointEntities = spot_check_fusionService.conditionalQueries(point_name,page);
            System.out.println(222);
            if (s_c_pointEntities.getCurrent() < 1){
                resultInfo.setFlag(false);
                resultInfo.setErrorMsg("查询为空！");
            }else {
                resultInfo.setFlag(true);
                resultInfo.setData(s_c_pointEntities);
            }

        }else if (groupOption != null){
            IPage<S_C_PointEntity> s_c_pointEntities = spot_check_fusionService.conditionalQueries(CalculationIsType.calculationIsGroupTypeToMySql(CalculationIsType.calculationIsGroupType(groupOption)), true,page);
            System.out.println(333);
            if (s_c_pointEntities.getCurrent() < 1){
                resultInfo.setFlag(false);
                resultInfo.setErrorMsg("查询为空！");
            }else {
                resultInfo.setFlag(true);
                resultInfo.setData(s_c_pointEntities);
            }
        }else {
            resultInfo.setFlag(false);
            resultInfo.setErrorMsg("查询条件错误！");
        }
        packagedData.writeValue(resultInfo,httpServletResponse);
    }catch (Exception e) {
            e.printStackTrace();
        }
    }

    @RequestMapping("findAllS_CDailyStatus")
    public void findAllS_CDailyStatus(HttpServletResponse httpServletResponse) throws IOException {
        List<S_C_StatusEntity> allS_cDailyStatus = spot_check_fusionService.findAllS_CDailyStatus();
        ResultInfo resultInfo = new ResultInfo();
        PackagedData packagedData = new PackagedDataImpl();
        resultInfo.setData(allS_cDailyStatus);
        packagedData.writeValue(resultInfo,httpServletResponse);
    }

    @RequestMapping("getS_CDataStatus")
    public void getS_CDataStatus(@RequestParam int page, @RequestParam String pointName,@RequestParam String date,HttpServletResponse httpServletResponse,HttpServletRequest httpServletRequest) throws IOException {
        DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd");
        Date date1 = null;
        ResultInfo resultInfo = new ResultInfo();
        PackagedData packagedData = new PackagedDataImpl();
        try {
            date1 = dateFormat.parse(date);
        }catch (ParseException e){
            e.printStackTrace();
        }
        IPage<S_C_DatesEntity> s_cDataStatus = spot_check_fusionService.getS_CDataStatus(page, pointName, date1);
        resultInfo.setData(s_cDataStatus);
        packagedData.writeValue(resultInfo,httpServletResponse);
    }



}

